package com.ruoyi.ihome.service.impl;

import java.util.List;

import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.ihome.domain.Facility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ihome.mapper.DistrictTypeMapper;
import com.ruoyi.ihome.domain.DistrictType;
import com.ruoyi.ihome.service.IDistrictTypeService;

import javax.annotation.Resource;

/**
 * 区域分类Service业务层处理
 * 
 * @author mage
 * @date 2024-08-13
 */
@Service("districtTypeService")
public class DistrictTypeServiceImpl implements IDistrictTypeService 
{
    @Resource
    private DistrictTypeMapper districtTypeMapper;

    @Autowired
    private RedisCache redisCache;

    /**
     * 查询区域分类
     * 
     * @param id 区域分类主键
     * @return 区域分类
     */
    @Override
    public DistrictType selectDistrictTypeById(Long id)
    {
        return districtTypeMapper.selectDistrictTypeById(id);
    }

    /**
     * 查询区域分类列表
     * 
     * @param districtType 区域分类
     * @return 区域分类
     */
    @Override
    public List<DistrictType> selectDistrictTypeList(DistrictType districtType)
    {
        //  带条件查询区域
        if(districtType != null)
            return districtTypeMapper.selectDistrictTypeList(districtType);
        //  查询所有区域
        List<DistrictType> list = (List<DistrictType>) redisCache.getCacheObject("selectDistrictTypeList");
        if(list == null){
            list = districtTypeMapper.selectDistrictTypeList(districtType);
            redisCache.setCacheObject("selectDistrictTypeList",list);
        }
        return list;
    }

    /**
     * 新增区域分类
     * 
     * @param districtType 区域分类
     * @return 结果
     */
    @Override
    public int insertDistrictType(DistrictType districtType)
    {
        return districtTypeMapper.insertDistrictType(districtType);
    }

    /**
     * 修改区域分类
     * 
     * @param districtType 区域分类
     * @return 结果
     */
    @Override
    public int updateDistrictType(DistrictType districtType)
    {
        return districtTypeMapper.updateDistrictType(districtType);
    }

    /**
     * 批量删除区域分类
     * 
     * @param ids 需要删除的区域分类主键
     * @return 结果
     */
    @Override
    public int deleteDistrictTypeByIds(Long[] ids)
    {
        return districtTypeMapper.deleteDistrictTypeByIds(ids);
    }

    /**
     * 删除区域分类信息
     * 
     * @param id 区域分类主键
     * @return 结果
     */
    @Override
    public int deleteDistrictTypeById(Long id)
    {
        return districtTypeMapper.deleteDistrictTypeById(id);
    }
}
